package com.api.shopapi.mapper;

import com.api.shopapi.entity.SBJHeartRateData;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface SBJHeartRateDataMapper {

    @Insert("insert into sbj_heart_rate_data (HeartRateDataCode,HeaderCode,DeviceId,HeartBeat,RespiratoryRate,BodyMove," +
            "Temperature,OnBed,SendDateTime,AddTime) values " +
            "(#{heartRateData.HeartRateDataCode},#{heartRateData.HeaderCode},#{heartRateData.DeviceId},#{heartRateData.HeartBeat}," +
            "#{heartRateData.RespiratoryRate},#{heartRateData.BodyMove},#{heartRateData.Temperature},#{heartRateData.OnBed},#{heartRateData.SendDateTime},#{heartRateData.AddTime})")
    int insert(@Param("heartRateData") SBJHeartRateData heartRateData);



    @Select("select * from sbj_heart_rate_data sh left join yj_header yh on sh.HeaderCode = yh.HeaderCode where " +
            "sh.DeviceId=#{deviceId} and sh.AddTime between #{startTime} and #{endTime} " +
            "and yh.Name='HeartRateData' " +
            "order by sh.AddTime desc")
    List<SBJHeartRateData> getHeartRateDataPageByDeviceId(@Param("deviceId") String deviceId,@Param("startTime") String startTime,@Param("endTime") String endTime);


}
